﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using Odds.Entity;
using Odds.DataAccess;

public partial class Football_14Game_IssueList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        List<OddsIssue> source = new OddsIssueController().GetAllOddsIssue();
        if (source.Count > 0)
        {
            panel.InnerHtml = CreateTable(source);
        }
    }

    private string CreateTable(List<OddsIssue> oddsIssueSet)
    {
        StringBuilder result = new StringBuilder();
        int columnCount = 10;
        result.AppendFormat(@"<table class=""tableMain"">");
        for (int i = 0; i < oddsIssueSet.Count; i++)
        {
            if (i % columnCount == 0)
            {
                result.AppendFormat("<tr>");
            }

            result.AppendFormat(@"<td><a target=""_blank"" href=""IssueItemList.aspx?issueID={0}"">{1}</a></td>", 
                oddsIssueSet[i].IssueID, oddsIssueSet[i].IssueRealID.ToString());

            if (i % columnCount == 9)
            {
                result.AppendFormat("</tr>");
            }
        }
        result.AppendFormat("</table>");
        return result.ToString();
    }
}